﻿Ext.define('app.prm.detail.DetailController', {
    extend: 'Ext.app.ViewController',
    alias: 'controller.detail',
    init: function () {
        var me = this;
    },
    onInit: function (view) {
        App.AjaxGet('/api/services/app/project/Get?id=' + view.paramsId, function (data) {
            console.log("*********************************");
            console.log(data.result);
            console.log("*********************************");
            view.getViewModel().setData(data.result);
        });
    },
    onEditInfo: function (panel, tool, event) {
        var view = this.getView();
        var win = Ext.create("app.prm.detail.EditInfo", { title: '编辑项目信息', projectId: view.paramsId });
        win.on("savesuccess", function (data) {
            this.onInit(view);
            win.close();
        }, this);
        win.show();
    },
    onEditCose: function (panel, tool, event) {
        var view = this.getView();
        var win = Ext.create("app.prm.detail.EditCost", { title: '编辑项目成本', projectId: view.paramsId });
        win.on("savesuccess", function (data) {
            this.onInit(view);
            win.close();
        }, this);
        win.show();
    },
    onTeamComment: function () {
        var view = this.getView();
        var model = view.getViewModel();

        var win = Ext.create("app.prm.detail.TeamEvaluation", {
            projectId: view.paramsId,
            teamCommentStatus: model.get('teamCommentStatus')
        });
        win.show();
    },
    onOpenDocument: function () {
        var view = this.getView();
        //var mainPanel = view.up('tabpanel');
        //mainPanel.newTab(view.paramsId, "app.prm.document.Index", "项目文档");
        this.redirectTo('app.prm.document.Index/' + view.paramsId);
    },
    onDiscuss: function ()
    {
        //项目提问
        var view = this.getView();
        //var mainPanel = view.up('tabpanel');
        //mainPanel.newTab(view.paramsId, "app.prm.detail.Discuss", "项目讨论");
        this.redirectTo('app.prm.detail.Discuss/' + view.paramsId);
    }
});
